@extends('layouts.app')

@section('htmlheader_title')
	基本设置
@endsection

@section('contentheader_title')
	基本设置
@endsection

@section('contentheader_description')
	自定义菜单
@endsection

@section('main-content')
	<div style="width: 200px;margin-bottom: 20px">
	<button type="button" class="btn btn-block btn-success  btn-lg" id="add">添加菜单栏</button>
	</div>

	<div class="box">
		<!--搜索开始
		<div class="row">
			<div class="col-sm-6">
				<div id="example1_filter" class="dataTables_filter">
					<label>Search:<input type="search" class="form-control input-sm" placeholder="" aria-controls="example1" /></label>
				</div>
			</div>
		</div>
		搜索结束-->
		<!-- /.box-header -->

		<div class="box-body">
			<table id="example1" class="table table-bordered table-striped">
				<thead>
				<tr>
					<th>菜单名称</th>
					<th>菜单类型</th>
					<th>类型值</th>
					<th>排序</th>
					<th>是否开启</th>
					<th>创建时间</th>
					<th>操作</th>
				</tr>
				</thead>
				<tbody>
				@foreach ($nav as $value)
					<tr>
						<td>{{$value->nav_name}}</td>
						<td>{{$value->nav_type}}</td>
						<td>{{$value->value}}</td>
						<td>{{$value->sort}}</td>
						<td>{{$value->is_opend}}</td>
						<td>{{$value->created_at}}</td>
						<td>
							<button type="button" class="btn btn-info" onclick="edit({{$value->id}})">编辑</button>
							<button type="button" class="btn btn-danger"  onclick="del({{$value->id}},{{$value->pid}})">删除</button>
						</td>
					</tr>
					@if($value->pid==0)
						@foreach($child[$value->id] as $valueChild)
							<tr>
								<td>├├  {{$valueChild['nav_name']}}</td>
								<td>{{$valueChild['nav_type']}}</td>
								<td>{{$valueChild['value']}}</td>
								<td>{{$valueChild['sort']}}</td>
								<td>{{$valueChild['is_opend']}}</td>
								<td>{{$valueChild['created_at']}}</td>
								<td>
									<button type="button" class="btn btn-info" onclick="edit({{$valueChild['id']}})">编辑</button>
									<button type="button" class="btn btn-danger" onclick="del({{$valueChild['id']}},{{$valueChild['pid']}})">删除</button>
								</td>
							</tr>
						@endforeach
					@endif


				@endforeach
				</tbody>
			</table>

		</div>
		<!-- /.box-body -->
	</div>
	<!-- /.box -->
	<div style="width: 200px;margin-bottom: 20px;margin-left: 650px">
		<button type="button" class="btn btn-block btn-warning   btn-lg" id="make_menu">生成自定义菜单栏</button>
	</div>
	<script>
       //生成自定义菜单栏
		$('#make_menu').click(function () {
			location.href='{{url('wechat/makeMenu')}}';
		})
	   //添加菜单栏
		$('#add').click(function () {
			layer.open({
				type: 2,
				title: '添加菜单栏',
				maxmin: true,
				shadeClose: true, //点击遮罩关闭层
				area : ['800px' , '550px'],
				content: ['{{url('BaseSet/add')}}']
			});
		})
     //编辑菜单栏
		function edit(id) {
			var id=id;
			var url='{{url('BaseSet/edit')}}'+'?id='+id;
			layer.open({
				type: 2,
				title: '编辑菜单栏',
				maxmin: true,
				shadeClose: true, //点击遮罩关闭层
				area : ['800px' , '550px'],
				content: [url]
			});
		}
		//删除菜单栏
		function del(id,pid){
			var url='{{url('BaseSet/del')}}'+'?id='+id+'&pid='+pid;
			location.href=url;
		}
	</script>
	</div>

@endsection
